package com.huarui.companypackage.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.ewaf.framework.dao.impl.BaseDaoImpl;
import org.springframework.orm.ibatis.SqlMapClientCallback;

import com.huarui.companypackage.dao.IBuyPackageItemDao;
import com.huarui.companypackage.model.BuyPackageItem;
import com.ibatis.sqlmap.client.SqlMapExecutor;


public class BuyPackageItemDaoImpl extends BaseDaoImpl implements IBuyPackageItemDao {

	@Override
	public void batchInsertBuyPackageItem(final List<BuyPackageItem> buyPackageItems) {
		
		getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
			
			@Override
			public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
				executor.startBatch();
				int batch = 0;
				for(BuyPackageItem buyPackageItem : buyPackageItems){
					executor.insert(namespace+".create",buyPackageItem);
					batch++;
					if(batch == 10){
						executor.executeBatch();
						batch = 0;
					}
				}
				executor.executeBatch();
				return null;
			}
		});
		
	}

}
